package com.fulei.device;

import com.bjfl.saleManager.util.LogUtil;
import com.fulei.logic.EastUpsOperate;

public class EastUpsDevice
{
  private String deviceType;
  private String comNo;
  private String baudRate;
  
  public EastUpsDevice(String devType, String com, String brn)
  {
    this.deviceType = devType;
    this.comNo = com;
    this.baudRate = brn;
  }
  
  public int upsCloseTime(String closeTime)
  {
    int return_data = 0;
    try
    {
      if ("EASTUPS".equals(this.deviceType))
      {
        EastUpsOperate.comNo = this.comNo;
        EastUpsOperate.baudRate = this.baudRate;
        return_data = EastUpsOperate.colseTimeCmd(closeTime);
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("EastUpsCloseTime 异常:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
  
  public int upsRestTime(String upsData)
  {
    int return_data = 0;
    try
    {
      if ("EASTUPS".equals(this.deviceType))
      {
        EastUpsOperate.comNo = this.comNo;
        EastUpsOperate.baudRate = this.baudRate;
        return_data = EastUpsOperate.restTimeCmd(upsData);
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("EastUpsRestTime 异常:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
  
  public int upsClear()
  {
    int return_data = 0;
    try
    {
      if ("EASTUPS".equals(this.deviceType))
      {
        EastUpsOperate.comNo = this.comNo;
        EastUpsOperate.baudRate = this.baudRate;
        return_data = EastUpsOperate.clearCmd();
      }
    }
    catch (Exception ex)
    {
      LogUtil.writeExceptionLog("EastUpsClear 异常:" + ex.getMessage());
      return_data = -1;
    }
    return return_data;
  }
}
